//0. 解决长按时出现浏览器打开问题
document.oncontextmenu=function(e){
        e.preventDefault();
               };
//1. 根据语音内容获取视频列表
var getVideByVoice = function (voiceStr) {
    $("#searchInput").val(voiceStr);
    $.ajax({
        type: "POST",
        url: "../api/video/getVideoListByVoice",
        data:{
            voiceStr: voiceStr
        },
        contentType: "application/x-www-form-urlencoded",
        success: function (r) {
            if (r.code === 0) {
                console.log("获取语音视频列表");
                console.log(r);
                var videoInfo = r.videoInfo;
                var videoList = r.videoList;
                if(videoInfo){
                    $("#video-info").html(videoInfo);
                }
                if (videoList.length > 0 ) {
		            $('#msg3').fadeOut();
                    fillVideoData(videoList);
                }else{
		            $("#msg").html('<i class="icon icon-40 f20 f-green"></i>您查询的视频不存在，请重新查询');
                    $('#msg3').fadeIn();
                }
            } else {
                $("#msg").html('<i class="icon icon-40 f20 f-green"></i>您查询的格式不正确，请重新查询。<br/>正确格式为：科目+页码，例如：语文第八页');
                $('#msg3').fadeIn();
                $.toast(r.msg, "text");
            }
        }
    });
}

var fillVideoData = function(videoList){
    var html = '';
    videoList.forEach(function(value,index,array){
        var videoName = value.videoName;
        html +='<a class="weui-cell weui-cell_access" href="./video_detail.html?videoId='+value.id+'">';
        html +='<div class="weui-cell__hd"><p class="page-no"><b>'+value.pageNo+'</b><span style="font-size:1px">页</span></p></div>';
        html +='<div class="weui-cell__bd">';
        html +='<p>教版信息'+value.versionName+'</p>';
        html +='<p>'+value.unitName+'</p>';
        html +='<p style="font-size: 13px;color: #888888;">'+videoName+'</p>';
        html +='</div>';
        html +='<div class="weui-cell__ft"></div>';
        html +='</a>';

    });
    $("#showVideoList").html(html);
}

var doTouch = function () {
     console.log("开始录音");
     $('.audio-group').show();
     Jssdk.startRecord();
}

var doTouchend =function () {
     console.log("结束录音");
     Jssdk.endRecord();
     $('.audio-group').hide();
}
